﻿/**
 * Peter
 * Created by: Peter Development Team
 *    http://peter.codeplex.com/
 * 
 * GNU General Public License version 2 (GPLv2)
 *    http://peter.codeplex.com/license
 **/

using System.Collections.ObjectModel;
using System.Windows.Input;
using Peter.Common.MainMenu;

namespace Peter.Common
{
   /// <summary>
   /// Represents a quick access menu item in peter.
   /// </summary>
   public class PeterQuickAccessItem : ViewModelBase, IMainMenuQuickAccessItem
   {
      private string m_ToolTip;
      private ICommand m_Command;
      private bool m_IsEnabled = true;
      private bool m_IsVisible = true;
      private object m_CommandParameter;
      private MainMenuIcon m_Icon = MainMenuIcon.None;

      /// <summary>
      /// Initializes a new quick access menu item.
      /// </summary>
      public PeterQuickAccessItem ()
      {
         this.Children = new ObservableCollection <IMainMenuItem> ();
      }

      /// <summary>
      /// Gets the priority of the menu item.
      /// </summary>
      public int Priority { get; set; }

      /// <summary>
      /// Gets the url of the icon to display for the menu item.
      /// </summary>
      public MainMenuIcon Icon
      {
         get { return this.m_Icon; }
         set
         {
            if (this.m_Icon != value)
            {
               this.m_Icon = value;
               this.OnPropertyChanged ("Icon");
            }
         }
      }

      /// <summary>
      /// Gets or Sets if the item is enabled.
      /// </summary>
      public bool IsEnabled
      {
         get { return this.m_IsEnabled; }
         set
         {
            if (this.m_IsEnabled != value)
            {
               this.m_IsEnabled = value;
               this.OnPropertyChanged ("IsEnabled");
            }
         }
      }

      /// <summary>
      /// Gets the tool tip to display for the menu item.
      /// </summary>
      public string ToolTip
      {
         get { return this.m_ToolTip; }
         set
         {
            if (this.m_ToolTip != value)
            {
               this.m_ToolTip = value;
               this.OnPropertyChanged ("ToolTip");
            }
         }
      }

      /// <summary>
      /// Gets a command parameter for the menu item.
      /// </summary>
      public object CommandParameter
      {
         get { return this.m_CommandParameter; }
         set
         {
            if (this.m_CommandParameter != value)
            {
               this.m_CommandParameter = value;
               this.OnPropertyChanged ("CommandParameter");
            }
         }
      }

      /// <summary>
      /// Gets the action for the menu to perform when clicked.
      /// </summary>
      public ICommand Command
      {
         get { return this.m_Command; }
         set
         {
            if (this.m_Command != value)
            {
               this.m_Command = value;
               this.OnPropertyChanged ("Action");
            }
         }
      }

      /// <summary>
      /// Gets or Sets if the menu item is visible.
      /// </summary>
      public bool IsVisible
      {
         get { return this.m_IsVisible; }
         set
         {
            m_IsVisible = value;
            this.OnPropertyChanged ("IsVisible");
         }
      }

      /// <summary>
      /// Gets the list of children menu items.
      /// </summary>
      public ObservableCollection<IMainMenuItem> Children { get; private set; }
   }
}
